/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.miage.pki.service;

import java.io.OutputStream;
import java.security.cert.X509CRLEntry;
import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.List;
import org.bouncycastle.asn1.x509.KeyUsage;

import com.miage.pki.obj.CertificateAndName;
import com.miage.pki.obj.User;


/**
 *
 * @author Gaetan
 */
public interface PKIService{
    
    public final static String basePath = "C:/certs/";
    
    public final static String keyStorePath = basePath + "keyStores/";
    public final static String certificatePath = basePath + "certificates/";
    public final static String revocationPath = basePath + "revocations/";
    public final static String keyPath = basePath + "keys/";

    public boolean createCertificate(String algo, String startDate, String expiryDate, KeyUsage keyUsage, String alias, String subjectDN, String username, String password, String email);
    
    public boolean writeX509CertificateFile(OutputStream os, String username, String password, String alias);
    
    public List<CertificateAndName> getAllCertificates(String username, String password);
    
    public CertificateAndName getCertificate(String username, String password, String alias);
    
    public boolean writePKCS12CertificateFile(OutputStream os, String username, String password, String alias, String pk12password);
    
    public boolean writeKeyFile(OutputStream os, String username, String password, String alias);
    
    public int isValid(X509Certificate cert);
    
    public boolean isRevoked(String username, X509Certificate cert);
    
    public void revoke(String username, X509Certificate cert, int reason);
    
    public List<X509CRLEntry> getRevocationList(String username);
    
    public void fillUserInformations(User u, String password);
    
    
}